public class Test22 {
    public static void main(String[] args) {
        int count = 0;

        for (int i = 1; i <= 100; i++) {
            boolean flag = IsPrime(i);

            if (flag == true) {
                System.out.print(i + " ");
                count++;
                if (count % 5 == 0) {
                    System.out.println();
                }
            }

        }
    }

    public static boolean IsPrime(int num) {
        for (int i = 2; i < num; i++) {
            if (num % i == 0) {
                return false;
            }
        }

        return true;
    }
}
